<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>微信JS-SDK Demo</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
    <link rel="stylesheet" href="http://demo.open.weixin.qq.com/jssdk/css/style.css?ts=1420774989">

    <!-- head 中 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">

    <!-- body 最后 -->
    <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>
    <script src="/res/vue.js"></script>


</head>
<body ontouchstart="">
<div class="wxapi_container" id="app">

    <div class="weui-cells weui-cells_form">

        <div class="weui-cell">
            <div class="weui-cell__bd">
                <button class="btn btn_primary" id="huoqu">获取位置</button>
            </div>
        </div>
        <div class="weui-cell">
            <input id="id_securityCode_input">
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <button class="btn btn_primary" id="scanQRCode">扫码</button>
            </div>
        </div>

        <div class="weui-cell">
            <div class="weui-cell__bd">
                <button class="btn btn_primary">
                    <a href="" data-miniprogram-appid="wx2c9d7a0263163fe0" data-miniprogram-path="pages/index/index">点击跳小程序</a>
                </button>
            </div>
        </div>

    </div>

</div>
</body>

<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>

    wx.config({
        debug: false,
        appId: '{$jsconfig.appId}',
        timestamp: '{$jsconfig.timestamp}',
        nonceStr: '{$jsconfig.noncestr}',
        signature: '{$jsconfig.signature}',
        jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',
            'translateVoice',
            'startRecord',
            'stopRecord',
            'onRecordEnd',
            'playVoice',
            'pauseVoice',
            'stopVoice',
            'uploadVoice',
            'downloadVoice',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'getNetworkType',
            'openLocation',
            'getLocation',
            'hideOptionMenu',
            'showOptionMenu',
            'closeWindow',
            'scanQRCode',
            'chooseWXPay',
            'openProductSpecificView',
            'addCard',
            'chooseCard',
            'openCard'
        ]
    });

    wx.ready(function () {

        // 获取位置
        $("#huoqu").click(function(){
            wx.getLocation({
                type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
                success: function (res) {
                    var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                    var longitude = res.longitude ; // 经度，浮点数，范围为180 ~ -180。
                    var speed = res.speed; // 速度，以米/每秒计
                    var accuracy = res.accuracy; // 位置精度

                    alert(latitude);
                    alert(longitude);
                    alert(speed);
                    alert(accuracy);

                    getAddress(latitude,longitude);

                }
            });
        })

        // 扫一扫
        $("#scanQRCode").click(function() {
            wx.scanQRCode({
                // 默认为0，扫描结果由微信处理，1则直接返回扫描结果
                needResult : 1,
                desc : 'scanQRCode desc',
                success : function(res) {
                    //扫码后获取结果参数赋值给Input
                    var url = res.resultStr;
                    //商品条形码，取","后面的
                    if(url.indexOf(",")>=0){
                        var tempArray = url.split(',');
                        var tempNum = tempArray[1];
                        $("#id_securityCode_input").val(tempNum);
                    }else{
                        $("#id_securityCode_input").val(url);
                    }
                }
            });
        });

    });

    wx.error(function (res) {
        alert(res.errMsg);
    });

</script>

</html>